package com.ljlobserv.demo.dao;

import com.ljlobserv.demo.entity.Article;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName：ArticleDaoImpl
 * Description：
 * Create by Administrator
 * Date：2020/8/25 0025 11:14
 */
public class ArticleDaoImpl implements ArticleDao {
    private List<Article> list = new ArrayList();
    private long id = 1;

    public void insert(Long uid) {
        Article article = new Article();
        article.setId(id);
        article.setContent("我是文章内容"+id);
        article.setUid(uid);
        list.add(article);
        id++;
        System.out.println("ArticleDaoImpl执行添加数据..."+article);
    }

    public void delete(Long id) {
        for (int i = 0; i < list.size(); i++) {
            Article article = list.get(i);
            if(id.equals(article.getId())){
                list.remove(article);
                System.out.println("ArticleDaoImpl执行删除数据..."+article);
            }
        }

    }
}
